def main():
    while True:
        try:
            s=0
            n=input()
            for i in range(len(n)):
                if n[i]=='0' or n[i]=='6' or n[i]=='9':
                    s+=1
                if n[i]=='8':
                    s+=2
            print(s)
        except:
            break
        
main()